import request from '../../utils/request';
import PublicService from '../../services/PublicService'
import PointManageService  from '../../services/stationRule/pointManageService'

export default {
  namespace: 'pointManage',
  state: {

    selectedRows:[], // 选中行
    deviceId:'', // 设备id 用来获取左侧数据参数
    size: 10,
    page: 1,
    total: 20,
    initData:{},
    loading: false,
    dataSource:[],
    isVisible:false,
    treeData:[],
  },
  effects: {
    // 获取左侧树数据
    *getLeftTree({payload},{put,call}){
      let res = yield call(PointManageService.getLeftTree);
      console.log(res);
    },
    //获取右侧数据
    *getRightData({payload},{put,call,select}){
      let deviceId = yield select(state => state.pointManage.deviceId);

      let res = yield call(PointManageService.getRightData,deviceId);
      console.log(res);

    },

    *deleteHandle({payload},{put,call,select}){

    },
    *submit({payload},{put,call,select,}){
      yield put({type:'saveInfo',payload:{isVisible:false}})
    },
    * saveInfo({payload}, {put, call, take, select}) {
      let obj = PublicService.deepClone(payload);
      yield put({type: 'save', payload: {...obj}});
    }
  },
  reducers: {
    save(state, {payload}) {
      console.log(payload, 'reduce');
      return {...state, ...payload};
    },
  },
};
